//
//  UserInfo.m
//  ICard
//
//  Created by fanshao on 11-2-22.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "UserInfo.h"


@implementation UserInfo
static UserInfo * shardInfo = nil;
@synthesize ppt;
@synthesize cardArray;

+(UserInfo*)shardUserInfo{
	@synchronized(self){
		if (!shardInfo) {
			shardInfo = [[UserInfo alloc] init];
			[shardInfo loadPref];
		}
	}
	return shardInfo;
}

- (void)loadPref{
	NSString *pptInfo = [[NSUserDefaults standardUserDefaults] objectForKey:@"userppt"];
	if (pptInfo) {
		self.ppt = pptInfo;
	}
	else {
		self.ppt = nil;
	}

	NSMutableArray *tempArray = [[NSUserDefaults standardUserDefaults] objectForKey:@"cardArray"];
	if (tempArray) {
		self.cardArray = [NSMutableArray arrayWithArray:tempArray];
	}
	else {
		self.cardArray = [NSMutableArray array];
	}

}

- (void)savePref{
	
	[[NSUserDefaults standardUserDefaults] setObject:self.ppt forKey:@"userppt"];
	[[NSUserDefaults standardUserDefaults] setObject:self.cardArray forKey:@"cardArray"];
}
@end
